﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using AutoMapper;

using Revis.VClinicNet.Core.Domain;

namespace Revis.VClinicNet.App.Internal.Dto.Mappers
{
    public class VisitDtoMapper : IDtoMapper
    {
        public static Func<Visit, string> Room = (v) => {
            DayOfWeek day = v.Date.DayOfWeek;
            WorkTime workTime = v.Doctor.GetWorkTime(day);
            return workTime.Room;
        };

        public void Map()
        {
            Mapper.CreateMap<Visit, VisitInfoDto>()
                .ForMember(v => v.PatientName, mo => mo.MapFrom(v => PatientDtoMapper.Name(v.Patient)))
                .ForMember(v => v.DoctorName, mo => mo.MapFrom(v => DoctorDtoMapper.Name(v.Doctor)));

            Mapper.CreateMap<Visit, VisitDto>()
                .ForMember(v => v.Room, mo => mo.MapFrom(v => Room(v)));
        }
    }
}
